package com.icss.mqsp.db;

import java.util.List;
import java.util.Map;

public class DBManager
{
  private static final DBDataProvider db = new DBDataProvider();
  
  public static Map<String, Object> querySingleObject(String sqlId, Map<String, String> condition)
  {
    if ((sqlId == null) || (sqlId.equals(""))) {
      return null;
    }
    List dbResult = (List)db.getData(sqlId, condition);
    Map<String, Object> result = null;
    if ((dbResult != null) && (dbResult.size() > 0)) {
      result = (Map)dbResult.get(0);
    }
    return result;
  }
  
  public static List<Map<String, String>> queryForList(String sqlId, Map<String, String> condition)
  {
    if ((sqlId == null) || (sqlId.equals(""))) {
      return null;
    }
    List<Map<String, String>> dbResult = (List)db.getData(sqlId, condition);
    return dbResult;
  }
  
  public static List queryForList(String sqlId)
  {
    return queryForList(sqlId, null);
  }
  
  public static int update(String sqlId)
  {
    return update(sqlId, null);
  }
  
  public static int update(String sqlId, Map<String, String> condition)
  {
    return db.update(sqlId, condition);
  }
  
  public static int insert(String sqlId)
  {
    return insert(sqlId, null);
  }
  
  public static int insert(String sqlId, Map condition)
  {
    return db.insert(sqlId, condition);
  }
  
  public static int del(String sqlId)
  {
    return del(sqlId, null);
  }
  
  public static int del(String sqlId, Map condition)
  {
    return db.del(sqlId, condition);
  }
  
  public static int delAll(String sqlId, List list)
  {
    return db.delAll(sqlId, list);
  }
}
